package io.renren.modules.yckj.service;

import io.renren.common.page.PageData;
import io.renren.common.service.CrudService;
import io.renren.common.utils.Result;
import io.renren.modules.yckj.dto.InvoiceLogsDTO;
import io.renren.modules.yckj.dto.OrderDTO;
import io.renren.modules.yckj.entity.OrderEntity;
import io.renren.modules.yckj.entity.TeamRelationEntity;
import org.springframework.transaction.annotation.Transactional;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

/**
 * 预约列表
 *
 * @author Mark sunlightcs@gmail.com
 * @since 1.0.0 2025-04-25
 */
public interface OrderService extends CrudService<OrderEntity, OrderDTO> {

    PageData<OrderDTO> pageForAdmin(Map<String, Object> params);
    /**
     * @param params 对数
     * @return BookTotalTime 求和结果
     */
    BigDecimal sumActualAmount(Map<String, Object> params);

    /**
     * @param params 对数
     * @return BookTotalTime 求和结果
     */
    BigDecimal sumBookTotalTime(Map<String, Object> params);

    /**
     * @param params 参数
     * @return 已预约时间
     */
    List<OrderDTO> getOrderList(Map<String, Object> params);

    PageData<OrderDTO> pageForApi(Map<String, Object> params);

    Result<Boolean> validatorAppoint(OrderDTO orderDTO) throws Exception;

    /**
     * 预约申请
     * @param dto 订单表
     * @return 是否成功
     */
    @Transactional(rollbackFor = Exception.class)
    boolean appoint(OrderDTO dto) throws Exception;

    @Transactional(rollbackFor = Exception.class)
    boolean teamApprove(OrderDTO orderDTO, Integer status, TeamRelationEntity teamRelation) throws Exception;

    @Transactional(rollbackFor = Exception.class)
    boolean updateAmount(OrderDTO orderDTO, BigDecimal actualAmount) throws Exception;

    @Transactional(rollbackFor = Exception.class)
    boolean cancel(OrderDTO orderDTO) throws Exception;

    @Transactional(rollbackFor = Exception.class)
    boolean balancePayByUser(Long userId, OrderDTO orderDTO) throws Exception;

    @Transactional(rollbackFor = Exception.class)
    boolean balancePayByUserByAdmin(Long userId, OrderDTO orderDTO) throws Exception;

    @Transactional(rollbackFor = Exception.class)
    boolean balancePayByUserForTeam(Long userId, OrderDTO orderDTO) throws Exception;

    @Transactional(rollbackFor = Exception.class)
    boolean balancePayByUserForTeamByAdmin(Long userId, OrderDTO orderDTO) throws Exception;

    @Transactional(rollbackFor = Exception.class)
    boolean balancePayByTeam(Long teamId, OrderDTO orderDTO) throws Exception;

    @Transactional(rollbackFor = Exception.class)
    boolean applyInvoice(OrderDTO orderDTO, InvoiceLogsDTO invoiceLogsDTO) throws Exception;
}